6 Improving Stability

Imports:

Load Dataset & Model

Load Data

6.3 Querying Modified Data

Load new model

Query

Encode full dataset

Using the encoder model we extract 10 features from all images in the combined test and train dataset.

Select 20 images and distort them

We are selecting the first 20 images of the combined dataset as test samples. Following we will search for the most similar images for each of the 20 images.

Function to add gaussian noise

This function allows to add arbitrary gaussian noise to a set of training data and returns the image set containing this noise.

Function to distort image

This function allows to apply a projective transformation to a single image that is returned. The images maintain their size (32x32x3). As library for he transformation c2 is used.

Function to show example images

Encode sample images

Implement different distance metrics for calculating pairwise distances of two data tuples

Use 'euclid', 'manhatten' or 'cosine' as metric input parameter when using this function.

Functions to plot most similar images

Calculate pairwise distances using "euclid" and improved model

Calculate pairwise distances using "euclid" and oldmodel

Calculate pairwise distances using "euclid" and improved model but original images as query input